<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of salidas
 *
 * @author marcelo.diaz
 */
class Salidas extends Controller{
    
	function Salidas()
	{
		parent::Controller("salidas");
        $this->load->model("Salidas_Model");
	}

	function index()
	{
      $email = "ALL";
      $this->email->from('conocepunta@gmail.com');
      $this->email->to('conocepunta@gmail.com');
      $this->email->subject('Salidas access');
      
      $data['page_title'] = "Las mejores salidas en Punta Alta - Bares - Restaurants - Pubs - Boliches";
      $data['meta_description'] = '<meta name="description" content="ConocePunta - Punta Alta, Buenos Aires, Argentina - Los mejores Bares, Restaurantes, Boliches, Pubs y lugares para salir en Punta Alta" />';
      $output = $this->load->view('head_view', $data, true);    
      
      $places = $this->Salidas_Model->_all();
      
      $navbar = $this->write_navbar();
      //iterate and parse places
            $output .= $navbar;
      $output .= "<div class='content centered'>";
      $output .= 	$this->write_custom_content($places);  
      $output .= 	$this->write_sidebar("bar restaurant pub boliches discos");
      $output .= "</div>";    
      //---------MAP---------
      $output .= $this->write_map();             
      $output .= $this->load->view('foot_view', "", true);
      $this->output->set_output($output);
      $this->email->message($email);
      //$this->email->send();
    }

    function name($place){
      $json = $this->Salidas_Model->get_place($place);      
      header('Content-Type:application/json');
      echo json_encode($json);	  
    }
	
    function all(){
      //return ($this->Salidas_Model->get_all());
      $json = $this->Salidas_Model->get_all();
      header('Content-Type:application/json');
      //!!!
      echo json_encode($json);  
    }

    function nombre($name = false){
      if ($name){
        $email = "[".$name."]";
        $this->email->from('conocepunta@gmail.com');
        $this->email->to('conocepunta@gmail.com');
        $this->email->subject('Salidas access');

        $navbar = $this->write_navbar();
        $name_replaced = str_replace("-", " ", $name);
        $data['page_title'] = $name_replaced." - Las mejores salidas en Punta Alta - Bares - Restaurants - Pubs - Boliches";
        $data['meta_description'] = '<meta name="description" content="'.$name_replaced.' - ConocePunta - Punta Alta, Buenos Aires, Argentina - Los mejores Bares, Restaurantes, Boliches, Pubs y lugares para salir en Punta Alta" />';              
        $output = $this->load->view('head_view', $data, true);
             
        $banner_adsense = '<div class="lheader"><script type="text/javascript"><!--
                                              google_ad_client = "pub-2113662635661393";
                                              
                                              google_ad_slot = "4418063429";
                                              google_ad_width = 728;
                                              google_ad_height = 90;
                                              //-->
                                              </script>
                                              <script type="text/javascript"
                                              src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                                              </script></div>';
        
        $output .= $navbar.
                   "<div class='content slim-content centered' style='height:120px'>".
        				$banner_adsense.
                   "</div>";  
                
		$content = "";
        //$place = $this->Salidas_Model->_place(strtolower($name));
		$place = $this->Salidas_Model->get_place($name);        
        if (!$place){
          $places = $this->Salidas_Model->_all();
          //iterate and parse places            
	      $content .= "<div class='content centered'>".
	 	      				"<p class='ui-state-highlight' style='width:50%; padding:10px; text-align:center;'>No hemos podido encontrar <strong>$name</strong>.</p>";
	      $content .= 	$this->write_custom_content($places);  
	      $content .= 	$this->write_sidebar("bar restaurant pub boliches discos");
	      $content .= "</div>"; 
          $email .= "NOT FOUND";
          $this->email->message($email);
          $this->email->send();
        } else{
	        //parse place
        	$content .= "<div class='content slim-content centered'>".
        					$this->write_specific_item($place).
        				"</div>";
        }
		$output .= $content;
		
        $output .= $this->load->view('foot_view', "", true);
        $this->output->set_output($output);
        //$this->email->message($email);
        //$this->email->send();
      }else{
        $this->index();
      }
    }
}

/* End of file salidas.php */
/* Location: ./system/application/controllers/salidas.php */
?>
